﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using fsw.Common;
using System.Text;
using System.Collections;

namespace fsw.Web.Card
{
    public partial class Show : Web.UI.ManagePage
    {
        protected string _url = string.Empty;        
        protected Model.Admin model_admin;//登录用户名 
        protected void Page_Load(object sender, EventArgs e)
        {
            model_admin = GetAdminInfo();
            this._url = DTRequest.GetQueryString("url");
            if (string.IsNullOrEmpty(this._url)) Response.End();
            string _urlcn = ChineseSpell.MakeSpellCode(this._url, "", SpellOptions.EnableUnicodeLetter);
            _urlcn = _urlcn.Replace(DTKeys.Path_File_No, DTKeys.Path_File_Upload_No).Replace(" ", "");
            DirFileHelper.CopyFiles(_url.Substring(1), _urlcn.Substring(1));
            if (model_admin.TypeId > 1) doAdd();
            Response.Redirect(_url);
        }
        /// <summary>
        /// 
        /// </summary>
        private void doAdd()
        {
            try
            {
                string _urlstr = this._url;
                _urlstr = _urlstr.Replace("/" + DTKeys.Path_File_No, "");
                string[] _urlarr = _urlstr.Split('/');
                int _m = _urlarr.Length;
                string PicName = _urlarr[_m - 1];
                ArrayList list = new ArrayList(_urlarr);
                list.RemoveAt(_m - 1);
                _urlarr = (string[])list.ToArray(typeof(string));
                string PicPath = string.Join("/", _urlarr);
                int Pid = Utils.StrToInt(_urlarr[1].Split('_')[0], 0);
                if (Pid == 0) Response.End();
                Model.Admin_Pic model = new Model.Admin_Pic();
                model.UserId = model_admin.Id;
                model.PicPath = PicPath;
                model.PicName = PicName;
                model.Pid = Pid;
                model.TypeId = 1;
                model.isStatus = 1;
                model.AddDate = Utils.ConvertDateTimeInt(DateTime.Now);
                BLL.Admin_Pic bll = new BLL.Admin_Pic();
                bll.Add(model);
            }
            catch { }
        }
    }
}